<?php
declare (strict_types = 1);

namespace app\admin\controller;

use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class Cate
{
    public function cate(){
        $parentid=Request::get('id',0);

        //一级分类查询
        $cates=\app\admin\model\Category::getCateF($parentid);
        View::assign('cates',$cates);

        //二级分类查询
        $er=\app\admin\model\Category::getCateEr();
        View::assign('er',$er);
        return view();
    }
    public function brand(){

        //表单数据接收
        $key=input('post.keywords');
        $show=input('post.show');
        $hot=input('post.img');
        $down=input('post.rec');
        $post=Request::param();


        //where条件拼接
        $where=[];
        if(input('?post.keywords') && $key!=""){$where[]=['brand_name','like','%{$key}%'];}//品牌关键字
        if(input('?post.show') && $show!=""){$where[]=['if_show','in',$show];}//是否显示
        if(input('?post.rec') && $down!=""){$where[]=['recommended','=',$down];}//是否推荐
        if(isset($hot) && in_array(1,$hot) && count($hot)==1){$where[]=['brand_logo','NOT NULL',''];}//有品牌图片
        if(isset($hot) && in_array(0,$hot) && count($hot)==1){$where[]=['brand_logo','NULL',''];}//无品牌图片

        //品牌信息查询
        $cates=\app\admin\model\Brand::getBrandList($where,$post);

        View::assign('brand',$cates);
        View::assign('show',$show);
        View::assign('img',$hot);
        View::assign('rec',$down);
        View::assign($post);
        return view();
    }
    public function cateedit(){
        return view();
    }

}
